package com.gitee.ed.arithmetic.leetcode.question.question_1_100.question_1_10;

import com.gitee.ed.arithmetic.leetcode.SolutionRunner;
import com.gitee.ed.arithmetic.leetcode.common.Question;
import com.gitee.ed.arithmetic.leetcode.solution.solution_1_100.solution_1_10.Solution10;

/**
 * @author hongda.li
 */
public class Question10 implements Question<Solution10> {
    @Override
    public String link() {
        return "https://leetcode.cn/problems/regular-expression-matching/description/";
    }

    @Override
    public String title() {
        return "10.正则表达式匹配";
    }

    @Override
    public String description() {
        return """
                给你一个字符串 s 和一个字符规律 p，请你来实现一个支持 '.' 和 '*' 的正则表达式匹配。
                '.' 匹配任意单个字符
                '*' 匹配零个或多个前面的那一个元素
                所谓匹配，是要涵盖 整个 字符串 s的，而不是部分字符串。
                """;
    }

    @Override
    public void test(Solution10 solution) {
        this.test1(solution);

        this.test2(solution);

        this.test3(solution);
    }

    private void test1(Solution10 solution) {
        SolutionRunner.checkString(false, solution.isMatch("aa", "a"));
    }

    private void test2(Solution10 solution) {
        SolutionRunner.checkString(true, solution.isMatch("aa", "a*"));
    }

    private void test3(Solution10 solution) {
        SolutionRunner.checkString(true, solution.isMatch("ab", ".*"));
    }
}
